package cn.pxs.tools;

import cn.pxs.entity.Type;
import cn.pxs.entity.User;
import cn.pxs.service.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;

import java.util.HashMap;
import java.util.Map;

public class Tools {

    public static Map RespJson(int stu,String msg,Object data){
        Map map = new HashMap();
        map.put("stu",stu);
        map.put("msg",msg);
        map.put("data",data);
        return map;
    }

    public static User getUser(){
        Object o = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        if(o.toString().startsWith("anonymous"))return null;
        User u = (User)o;
        return u;
    }



}
